from django.db import models
from django.contrib.auth.models import User
from datetime import datetime
from interview.models import DEGREE_TYPE
from django.utils.translation import gettext_lazy as _

JobTypes = [
    (0,"前端开发"),
    (1,"后端开发"),
    (2,"测试"),
    (3,"人工智能")
]

Cities = [
    (0,"北京"),(1,"上海"),(2,"广州"),(3,"深圳"),(4,"杭州"),
    (5,"天津"),(6,"西安"),(7,"苏州"),(8,"武汉"),(9,"厦门"),
    (10,"长沙"),(11,"成都"),(12,"大同"),(13,"郑州"),(14,"重庆")
]

class Job(models.Model):
    job_type = models.SmallIntegerField(blank=False, choices=JobTypes, verbose_name="职位类别")
    job_name = models.CharField(max_length=250, blank=False, verbose_name="职位名称")
    job_city = models.SmallIntegerField(blank=False, choices=Cities, verbose_name="工作地点")
    job_responsibility = models.TextField(max_length=1024, verbose_name="职位职责")
    job_requirement = models.TextField(max_length=1024, verbose_name="职位要求")
    #处理外键被删除,则相应的数据都会删除
    creator = models.ForeignKey(User, verbose_name="创始人",on_delete=models.CASCADE)
    created_date = models.DateTimeField(verbose_name="创建日期",default=datetime.now)
    modified_date = models.DateTimeField(verbose_name="修改时间",default=datetime.now)

    class Meta:
        verbose_name = '职位'
        verbose_name_plural= '职位列表'

class Resume(models.Model):
    username = models.CharField(max_length=135,verbose_name='姓名')
    applicant=models.ForeignKey(User,verbose_name="申请人",null=True,on_delete=models.CASCADE)
    city=models.CharField(max_length=135,verbose_name='城市')
    phone = models.CharField(max_length=135,verbose_name='手机号码')
    email=models.EmailField(max_length=135,blank=True,verbose_name='邮箱')
    apply_position = models.CharField(max_length=135,blank=True,verbose_name='应聘职位')
    born_address =models.CharField(max_length=135,blank=True,verbose_name='生源地')
    gender= models.CharField(max_length=135,blank=True,verbose_name='性别')

    attachment = models.FileField(upload_to='file/',blank=True,verbose_name='简历')
    #学校与学历信息
    bachelor_school=models.CharField(max_length=135,blank=True,verbose_name='本科学校')
    master_school=models.CharField(max_length=135,blank=True,verbose_name='研究生学校')
    doctor_school =models.CharField(max_length=135,blank=True,verbose_name='博士生学校')
    major=models.CharField(max_length=135,blank=True,verbose_name='专业')
    degree = models.CharField(max_length=135,choices=DEGREE_TYPE,blank=True,verbose_name='学历')
    created_date=models.DateTimeField(verbose_name="创建日期",default=datetime.now)
    modified_date=models.DateTimeField(verbose_name="修改日期",default=datetime.now)
    #候选人自我介绍,工作经历,项目经历
    candidate_introduction = models.TextField(max_length=1024,blank=True,verbose_name='自我介绍')
    work_experience = models.TextField(max_length=1024,blank=True,verbose_name='工作经历')
    project_experience= models.TextField(max_length=1024,blank=True,verbose_name='项目经历')

    class Meta:
        verbose_name = '简历'
        verbose_name_plural= '简历列表'
